<template>
    <div class="wraper">
      <li v-for="(item,index) in data1" :class="{'good-item':imgFlag,'good-item1':!imgFlag}" :key="index" @click="goGoodDetail(item.skuId)">
        <div class="icon">
          <!-- class="preview-img" @click="$preview.open(index, item)" -->
          <img v-lazy="{ 
              loading:'http://alicdn.avicare.cn/group1/M00/01/42/O24cYVk6SI2Aab6hAAAnOPGrbVU193.jpg', 
              src:imgPath(item.thumbnailPath),
              error: 'http://alicdn.avicare.cn/group1/M00/00/7F/O24cYVjt4GKAJovCAABAeKv7Krs288.jpg'}" @click="clickPic(item.thumbnailPath)"/>
              
        </div>
        <div class="content">
          <p>{{item.skuName}}</p>
          <div class="price">
            <span class="new">￥{{item.unitPrice}}</span>
            <span class="old">原价:￥{{item.listPrice}}</span>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>
<script>
import { imgUrl } from "@/utils/mixin";
export default {
  props: {
    data1: {
      type: Array,
      default: []
    },
    imgFlag: {
      type: Boolean,
      default: ""
    },
    shopName: {
      type: String,
      default: ""
    }
  },
  mixins: [imgUrl],
  data() {
    return {};
  },

  methods: {
    clickPic(path) {
      this.$emit("myPic", path);
    },
    imgPath(path) {
      if (this.shopName === "afk_mall") {
        return path;
      } else {
        return this.imgUrl(path);
      }
    },
    goGoodDetail(goodId) {
      this.$router.push({
        name: "goodDetail",
        query: { id: goodId }
      });
    }
  }
};
</script>
<style lang="less"scoped>
.wraper {
  overflow: hidden;
  .good-item {
    display: flex;
    flex: 1;
    border-top: 1px solid #dadada;
    padding-left: 0.3rem;
    padding-top: 0.22rem;
    padding-right: 0.48rem;
    padding-bottom: 0.2rem;
    .icon {
      width: 1.92rem;
      height: 1.92rem;
      padding-right: 0.2rem;
      vertical-align: top;
      img {
        width: 1.92rem;
        height: 1.92rem;
        padding-right: 0.2rem;
      }
    }
    .content {
      width: 4.6rem;
      height: 0.37rem;
      line-height: 0.56rem;
      vertical-align: middle;
      p {
        height: 0.84rem;
        width: 4.6rem;
        font-size: 0.3rem;
        color: #232323;
        text-align: left;
        white-space: wrap;
        line-height: 0.42rem;
        margin-bottom: 0.42rem;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }
      .price {
        .new {
          font-size: 0.4rem;
          color: #fd6d46;
          text-align: left;
          margin-right: 0.06rem;
        }
        .old {
          font-size: 0.26rem;
          color: #4e4e4e;
          text-align: left;
          line-height: 0.56rem;
          margin-bottom: 0.05rem;
          text-decoration: line-through;
        }
      }
    }
  }
  .good-item1 {
    box-sizing: border-box;
    list-style: none;
    width: 3.7rem;
    float: left;
    margin-top: 0.1rem;
    background-color: #fff;
    &:nth-child(odd) {
      float: left;
    }
    &:nth-child(even) {
      float: right;
    }
    .icon {
      width: 3.7rem;
      height: 3.7rem;
      position: relative;
      padding: 0.25rem;
      box-sizing: border-box;
      img {
        width: 100%;
        height: 100%;
      }
    }
    .content {
      width: 3.7rem;
      // height: 0.46rem;
      margin-bottom: 0.4rem;
      line-height: 0.4rem;
      // vertical-align: middle;
      > p {
        height: 1rem;
        padding-top: 0.2rem;
        width: 3.3rem;
        font-size: 0.28rem;
        color: #232323;
        text-align: center;
        white-space: wrap;
        line-height: 0.42rem;
        border-top: 1px dashed #ccc;
        margin: 0.2rem;
        box-sizing: border-box;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }
      .price {
        .new {
          color: #232323;
          font-size: 0.2rem;
          font-weight: 700;
          margin-left: 0.2rem;
          text-align: center;
        }
        .old {
          color: #b0b0b0;
          font-size: 0.2rem;
          font-weight: 700;
          text-decoration: line-through;
          text-align: center;
        }
      }
    }
  }
}
</style>
